﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class UserNotLoginCls
    {
        public string UserId;
        public string LoginName;
        public string FullName;
        public DateTime LastAccessed;
    }

    public class UserNotLoginParser
    {
        public static UserNotLoginCls CreateInstance()
        {
            //tao 1 class trang....
            UserNotLoginCls oUserNotLoginCls = new UserNotLoginCls();
            return oUserNotLoginCls;
        }

        public static UserNotLoginCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            UserNotLoginCls oUserNotLoginCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oUserNotLoginCls;
        }


        public static UserNotLoginCls ParseFromDataRow(DataRow dr)
        {
            UserNotLoginCls OUserNotLoginCls = new UserNotLoginCls();
            OUserNotLoginCls.UserId = (string)dr["UserId"];
            if (dr["UserId"] != DBNull.Value)
            {
                OUserNotLoginCls.UserId = (string)dr["UserId"];
            }
            if (dr["LoginName"] != DBNull.Value)
            {
                OUserNotLoginCls.LoginName = (string)dr["LoginName"];
            }
            if (dr["FullName"] != DBNull.Value)
            {
                OUserNotLoginCls.FullName = (string)dr["FullName"];
            }

            if (dr["LastAccessed"] != DBNull.Value)
            {
                OUserNotLoginCls.LastAccessed = (DateTime)dr["LastAccessed"];
            }
            return OUserNotLoginCls;
        }

        public static UserNotLoginCls[] ParseFromDataTable(DataTable dtTable)
        {
            UserNotLoginCls[] UserNotLogins = new UserNotLoginCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                UserNotLogins[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return UserNotLogins;
        }

    }
}



